import unittest
from selenium import webdriver


from Page.Page import login_page


from time import sleep
from  ddt import  ddt,file_data
from Page.Role_Page import Role_Page

@ddt
class Role_Case(unittest.TestCase):
    #测试固件
    def setUp(self):
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        lp = login_page(self.driver)
        lp.act_login('admin', '123456')
        sleep(2)
        print('开始')
    def tearDown(self):
        sleep(5)
        self.driver.quit()
        print('结束')

    #添加角色
    @file_data('D:\WuYi\Data_driven\yaml.yaml')
    def test_add(self,name,bm,miaoshu):
        po=Role_Page(self.driver)
        sleep(2)
        po.juese()
        po.tianjia()
        po.name(name)
        po.bm(bm)
        po.miaoshu(miaoshu)
        po.baocun()
    #修改内容并保存
    def test_update(self):
        po=Role_Page(self.driver)
        sleep(2)
        po.juese()
        po.xiugai()
        po.xiugainr()
        po.baocun()
    #删除
    def test_delete(self):
        po=Role_Page(self.driver)
        sleep(2)
        po.juese()
        po.shanchu()
    #切换页码
    def test_ye(self):
        po = Role_Page(self.driver)
        sleep(2)
        po.juese()
        po.quehuan()
    #查看页数
    def test_cha(self):
        po = Role_Page(self.driver)
        sleep(2)
        po.juese()
        po.chakan()
    #点击修改窗口最大化
    def test_update_da(self):
        po=Role_Page(self.driver)
        sleep(2)
        po.juese()
        po.xiugai()
        po.zuida()
    #点击修改窗口最小化
    def test_update_xiao(self):
        po=Role_Page(self.driver)
        sleep(2)
        po.juese()
        po.xiugai()
        po.zuixiao()
    #点击修改窗口取消
    def test_update_quxiao(self):
        po=Role_Page(self.driver)
        sleep(2)
        po.juese()
        po.xiugai()
        po.quxiao()